#pragma once
#include <vector>
#include "card.h"
namespace dymy
{
    namespace compartor
    {
        struct CardsClassify
        {
            enum CardsClassifyType
            {
                TYPE_INVALID = 0,
                TYPE_ROCKET_KING = 100,     //火箭王炸
                TYPE_BOMB_4 = 99,           //炸弹
                TYPE_ATTACH_4_2PAIR = 89,   //4带2对
                TYPE_ATTACH_4_2SINGLE = 88, //4带2单
                TYPE_ATTACH_4_1PAIR = 87,   //4带1对

                TYPE_ATTACH_3 = 79,        //3不带
                TYPE_ATTACH_3_PAIR = 78,   //3带对子
                TYPE_ATTACH_3_SINGLE = 77, //3带单

                TYPE_ATTACH_PLANE = 69,        //飞机不带
                TYPE_ATTACH_PLANE_PAIR = 68,   //飞机带对子
                TYPE_ATTACH_PLANE_SINGLE = 67, //飞机带单张
                TYPE_CONTINUES_2 = 59,         //连对
                TYPE_CONTINUES_1 = 49,         //顺子
                TYPE_PAIR_2 = 96,              //对子
                TYPE_SINGLE_1 = 95,            //单张
            };

            CardsClassifyType type = TYPE_INVALID;
            std::vector<card_t> c_king;          //是否有王炸
            std::vector<std::vector<card_t>> c4; //有几个炸弹
            std::vector<std::vector<card_t>> c3; //有几个3带
            std::vector<std::vector<card_t>> c2; //有几个对子
            std::vector<card_t> c1;              //有几个单张
            std::vector<std::vector<card_t>> c_continuous;
            operator std::string()
            {
                switch (type)
                {
                case CardsClassifyType::TYPE_ROCKET_KING:
                    return "火箭王炸";
                case CardsClassifyType::TYPE_BOMB_4:
                    return "炸弹";
                case CardsClassifyType::TYPE_ATTACH_4_2PAIR:
                    return "4带2对";
                case CardsClassifyType::TYPE_ATTACH_4_2SINGLE:
                    return "4带2单";
                case CardsClassifyType::TYPE_ATTACH_4_1PAIR:
                    return "4带1对";
                case CardsClassifyType::TYPE_ATTACH_3:
                    return "3不带";
                case CardsClassifyType::TYPE_ATTACH_3_PAIR:
                    return "3带对子";
                case CardsClassifyType::TYPE_ATTACH_3_SINGLE:
                    return "3带单";
                case CardsClassifyType::TYPE_ATTACH_PLANE:
                    return "飞机不带";
                case CardsClassifyType::TYPE_ATTACH_PLANE_PAIR:
                    return "飞机带对子";
                case CardsClassifyType::TYPE_ATTACH_PLANE_SINGLE:
                    return "飞机带单张";
                case CardsClassifyType::TYPE_CONTINUES_2:
                    return "连对";
                case CardsClassifyType::TYPE_CONTINUES_1:
                    return "顺子";
                case CardsClassifyType::TYPE_PAIR_2:
                    return "对子";
                case CardsClassifyType::TYPE_SINGLE_1:
                    return "单张";
                default:
                    return "无效";
                }
            }

            bool compute_cards(const std::vector<card_t> &cards);

            bool operator<=(const CardsClassify &) const noexcept;

            explicit operator bool() const noexcept;

            inline bool is_invalid() const noexcept
            {
                return type == TYPE_INVALID;
            }

            std::vector<card_t> collect_cards();
        };

        // void compute_cards(const std::vector<card_t> &cards, CardsClassify *classify_ptr);

        // /**
        //  * -1 右边牌不对
        //  * 0 右边牌小于小于等于左边牌
        //  * 1 右边牌大于左边牌
        //  * */
        // int8_t cards_compare_to(const CardsClassify *lhs, const CardsClassify *rhs);

        // void collect_cards(const CardsClassify *classify_ptr, std::vector<card_t> &cards_result, CardsClassifyType &type);

    }
}